<?php

use yii\db\Migration;

/**
 * Handles the creation of table `user_coupon`.
 */
class m180308_073407_create_user_coupon_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%user_coupon}}', [
            'id' => $this->primaryKey(),
            'user_id'=>$this->integer(10)->comment("用户"),
            'coupon_id'=>$this->integer(10)->comment("优惠券"),
            'catalog'=>$this->integer(10)->comment("优惠券分类"),
            'mark_id'=>$this->string(255)->comment("标识ID"),
            'created_at'=>$this->integer(11),
            'updated_at'=>$this->integer(11),
            'status'=>$this->smallInteger(3)->comment("状态"),
            'attempt'=>$this->integer(5)->comment("重试次数"),
            'error_msg'=>$this->text()->comment("错误信息"),
        ],$tableOptions);
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function down()
    {
        $this->dropTable('{{%user_coupon}}');
        return true;
    }
}
